//
//  YFSensorManager.h
//  SquashSpark
//
//  Created by Coollang on 2017/11/9.
//  Copyright © 2017年 Coollang-YF. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef void(^Completed)(BOOL success);

@interface YFSensorManager : NSObject

+ (instancetype)shareSensorManager;

//
/**
 * vc: push的控制器
 * isNecessaryOpenSensorVc:当为NO时，有链接设备时跳转到设备管理页，没有链接时跳转到搜索页
 * isNecessaryOpenSensorVc：当我YES时，不管有没有链接设备直接进入设备管理页
 */
+ (void)openSensorControllrWithVc:(UIViewController *)vc isNecessaryOpenSensorVc:(BOOL)isNecessaryOpenSensorVc;

#pragma mark - 循环自动升级
- (void)circulationReconnect;// 循环自动重连
- (void)removeTimer;// 停止自动重连


- (void)readBattery:(void(^)(BOOL success,NSInteger battery))block;

// 清楚缓存
- (void)cleanDeviceCache:(Completed)block;
// 修改设备名称
- (void)changeDeviceNameCallback:(void(^)(BOOL success,NSString *newName))changeNameBlock;

- (void)checkSensorUpadteWithParent:(UIViewController *)parentVc locationversion:(void(^)(BOOL versionSuccessful, NSString *version,NSInteger battery))locationVersion;
// 连接设备
- (void)connectThePeripheral:(LGPeripheral *)peripheral completed:(BleConnectBlock)block;
// 断开连接
- (void)disconnect:(BOOL)showAlert callback:(void(^)(BOOL success))block;


#pragma mark - 蓝牙数据同步
//1.获取需要同步天的数据
- (void)getBlueHomeDataWithComplete:(void(^)(NSArray<YFDayRecordItem *> *sportRecordItems, NSError *error))completed;

/*
 * 2.同步天的统计详情数据
 * everydayProgroess:具体的某一天的进度数据
 * allDayProgress: 总的进度
 * swingCompletion: 同步完成
 */
- (void)syncSwingDayDetailDataWithDayItems:(NSArray <YFDayRecordItem *>*)dayItems everydayProgress:(void(^)(YFDayRecordItem *dayItem,CGFloat dayProgress))everydayProgress allDayProgress:(void(^)(CGFloat totalProgress))allDayProgress compelete:(void (^)(void))completion;

#pragma mark - 同步网络上的统计详情数据
// 1.上传统计数据
- (void)updloadHomeDataToServerCompleted:(void(^)(NSError *error))completed;
// 2.上传天的详情数据
- (void)uploadDetailDataToServerCompleted:(void(^)(NSError *error))completed;

// 3.将服务器上的主页数据，上同步数据到本地
- (void)sysnHomeDataFromServerCallBlock:(void(^)(BOOL sysSuccess))callBlock;

@end
